<template>
  <el-dialog title="查看计费方式" :visible.sync="visible" :close-on-click-modal="false">
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="计费方式" name="first">
        <div class="first-pan" v-for="(item,index) in feeModel.billingGroupChargingPowerList" :key="index">
          <span>{{item.minPower}}</span>
          <span>至</span>
          <span>{{item.maxPower}}</span>
          <span>瓦</span>
          <span>{{item.everyHourSalesPrice}}/小时</span>
        </div>
      </el-tab-pane>
      <el-tab-pane label="收费方式" name="second">
        <div class="second-pan">
          <avue-crud ref="crud"
                     :data="feeModel.chargingModelMethodList"
                     :option="tableOption1"></avue-crud>
        </div>
      </el-tab-pane>
      <el-tab-pane label="vip收费" name="third">
        <div class="third-pan" v-if="feeModel.vipChargingVo.isEnable==1?true:false">
          <div>
            <div class="section-tlt">vip收费设置</div>
            <div class="item">
              <span>每次充电收费</span>
              <span>{{feeModel.vipChargingVo.vipEveryCharge}}</span>
              <span>元</span>
            </div>
            <div class="item">
              <span>每月最多次数</span>
              <span>{{feeModel.vipChargingVo.vipEveryMonthChargeNum}}</span>
              <span>次</span>
            </div>
          </div>
          <div class="section">
            <div class="section-tlt">vip用户<span class="total">用户数：{{vipTotal}}</span></div>
            <avue-crud ref="crud"
                       :page.sync="page"
                       :data="dataList"
                       :option="tableOption"
                       @current-change="currentChange"
                       @size-change="sizeChange"></avue-crud>
          </div>
        </div>
        <div v-else>
          <div class="empty">未启用</div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="新用户活动" name="fourth">
        <div class="second-pan" v-if="feeModel.activityChargeVo.isEnable==1?true:false">
          <div>新用户活动：已启用</div>
          <div>每次收费：{{feeModel.activityChargeVo.newUserChargingPrice}}元</div>
          <div>赠送次数：{{feeModel.activityChargeVo.newUserGiveCount}}次</div>
        </div>
        <div v-else>
          <div class="empty">未启用</div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="刷卡模式" name="five">
        <div class="second-pan">
          <div>刷卡模式：{{feeModel.isCardEnable==1?'已启用':'未启用'}}</div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <div class="footer">
      <el-button @click.stop="visible=false">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "fee-dialog",
  data(){
    return{
      id:'',
      vipTotal:0,
      visible:false,
      activeName:'first',
      feeModel:{
        activityChargeVo:{},
        vipChargingVo:{
          isEnable:0
        },
        isCardEnable:0
      },
      dataList:[],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      tableOption1:{
        border: true,
        index: true,
        indexLabel: '序号',
        stripe: false,
        menuAlign: 'center',
        align: 'center',
        refreshBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        header: false,
        menu: false,
        page:false,
        props: {
          label: 'label',
          value: 'value'
        },
        column: [{
          label: '收费方式',
          prop: 'billingType',
          type:'select',
          dicData:[{
            label:'时长收费',
            value:0
          },{
            label:'金额收费',
            value:1
          },{
            label:'智能充电',
            value:2
          }]
        },{
          label: '计费值',
          prop: 'tips',
        }]
      },
      tableOption:{
        border: true,
        index: true,
        indexLabel: '序号',
        stripe: false,
        menuAlign: 'center',
        align: 'center',
        refreshBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        header: false,
        menu: false,
        props: {
          label: 'label',
          value: 'value'
        },
        column: [{
          label: '姓名',
          prop: 'name',
        },{
          label: '手机号',
          prop: 'mobile',
        },{
          label: '总次数',
          prop: 'totalCount',
        },{
          label: '使用次数',
          prop: 'useCount',
        },{
          label: '到期时间',
          prop: 'endTime',
        }]
      }
    }
  },
  methods:{
    init(id){
      this.visible=true
      this.id=id
      this. activeName='first'
      this.getFee(id)
      this.getDataList()
    },
    getFee(id){
      this.$http({
        url:this.$http.adornUrl('/v1/merchant/charging/group/get/billing'),
        method:'get',
        params:this.$http.adornParams({id:id})
      }).then(({data})=>{
        this.feeModel=data.data
      })
    },
    getDataList (page) {
      this.$http({
        url: this.$http.adornUrl('/v1/merchant/charging/group/page'),
        method: 'get',
        params: this.$http.adornParams(
          Object.assign(
            {
              current: page == null ? this.page.currentPage : page.currentPage,
              size: page == null ? this.page.pageSize : page.pageSize
            },
            {id:this.id}
          )
        )
      }).then(({ data }) => {
        this.vipTotal=data.data.total
        this.dataList = data.data.records
      })
    },
    currentChange(val){
      this.page.currentPage=val
      this.getDataList(this.page)
    },
    sizeChange(val){
      this.page.pageSize=val
      this.getDataList(this.page)
    }
  }
}
</script>

<style lang="scss" scoped>
.first-pan{
  margin-bottom:20px;
  span:nth-child(1),span:nth-child(3){
    display: inline-block;
    width: 60px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #E8E8E8;
  }
  span:nth-child(2){
    display: inline-block;
    margin-left: 5px;
    margin-right: 5px;
  }
  span:nth-child(4){
    display: inline-block;
    margin-left: 5px;
  }
  span:nth-child(5){
    display: inline-block;
    margin-left: 50px;
  }
}
.second-pan{
  div{
    margin-top: 10px;
    font-size: 14px;
    color: #333333;
  }
}
.section{
  margin-top: 20px;
  .total{
    display: inline-block;
    margin-left: 50px;
    color: #333333;
    font-weight: normal;
    font-size: 14px;
  }
}
.section-tlt{
  color: #333333;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}
.third-pan{
  .item{
    padding-left: 20px;
    margin-top: 8px;
    &>span:nth-child(2){
      display: inline-block;
      width: 60px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      background-color: #E8E8E8;
      margin: 0px 20px;
    }
  }
}
.footer{
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
}
.empty{
  text-align: center;
  margin-top: 20px;
  font-size: 16px;
}
</style>
